<template>
	<sl-page title="招募合伙人">
		<view class="partner">
			<view class="">
				<sl-image :value="partner.image" mode="aspectFit"></sl-image>
			</view>
			<sl-flooter>
				<view class="btn-primary" @click="invite()">生成专属招募</view>
			</sl-flooter>
			<!-- 分享海报 -->
			<SharePosters :shareId.sync="shareId" :shareType="shareType" :painterImage="painterImage"
				:painterTextDescription="partner.name" painterTextLabel="专属招募" :targetPage="painterTargetPage">
			</SharePosters>
		</view>
	</sl-page>
</template>

<script>
	import PosterApi from '@/api/poster/poster.js';
	import ShareApi from '@/api/share/share.js';
	import Constants from '@/constants';
	import SharePosters from '@/pages/components/share/sharePosters.vue';
	//
	export default {
		//
		name: 'partner',
		//
		mixins: [Constants],
		//
		components: {
			SharePosters
		},
		//
		data() {
			return {
				options: {},
				query: {},
				partner: {},
				shareId: '',
				shareType: '',
				painterImage: '',
				painterTargetPage: 'xj_distribution/apply/marketing',
			};
		},
		//
		onLoad(options) {
			this.loadPage();
		},
		//
		methods: {
			//装在页面对象
			loadPage: async function() {
				try {
					this.query.type = 1;
					//todo，应该根据类型来查询，后台可能没有查询参数
					const res = await PosterApi.query(this.query, this.param);
					this.partner = res.obj.data[1];
					console.log('res: --------------------',res);
					this.painterImage = this.$options.filters['ImageSrc'](this.partner.image)
				} catch (error) {
					console.error(error);
				}
			},
			//生成专属邀请
			invite: async function() {
				const res = await ShareApi.saler(this.partner.id);
				this.shareId = res.obj.shareId
				this.shareType = res.obj.shareType;
			}
		}
	};
</script>

<style lang="scss" scoped>
	.partner {}
</style>